package com.lemon.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void onToastButtonClicked(View v) {
        switch (v.getId()) {
            case R.id.button_short:
                Toast.makeText(this,
                        this.getResources().getString(R.string.toast_show_short_text),
                        Toast.LENGTH_SHORT).show();
                break;
            case R.id.button_long:
                Toast.makeText(this,
                        this.getResources().getString(R.string.toast_show_long_text),
                        Toast.LENGTH_LONG).show();
                break;
            case R.id.button_put_extra:
                Intent intent = new Intent(MainActivity.this,PutExtraActivity.class);
                startActivity(intent);
                break;
        }

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu,menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId())
        {
            case R.id.menu_add:
                Toast.makeText(this,
                        item.getTitle(),
                        Toast.LENGTH_SHORT).show();
                break;
            case R.id.menu_remove:
                Toast.makeText(this,
                        item.getTitle(),
                        Toast.LENGTH_SHORT).show();
                break;
            case R.id.menu_push:
                Toast.makeText(this,
                        item.getTitle(),
                        Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(MainActivity.this,SecondActivity.class);
                startActivity(intent);
                break;
            case R.id.menu_finish:
                MainActivity.this.finish();
                break;
        }
        return super.onOptionsItemSelected(item);
    }
}
